home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / optivc32 / vulstd.h < prev    next >
C/C++ Source or Header  |  1999-03-06  |  7KB  |  181 lines

  1. /*  VULstd.h
  2.  
  3.   vector management functions for data type "unsigned long".
  4.  
  5.   Copyright (c) 1996-1999 by Martin Sander
  6.   All Rights Reserved.
  7. */
  8.  
  9. #ifndef __VULSTD_H
  10. #define __VULSTD_H
  11.  
  12. #if !defined( __VECLIB_H )
  13.    #include <VecLib.h>
  14. #endif
  15.  
  16. #ifdef __cplusplus
  17.     extern "C" {
  18. #endif
  19.  
  20. /*****************************  Generation ******************************/
  21.  
  22. ulVector  __vf  VUL_vector( ui size );
  23. ulVector  __vf  VUL_vector0( ui size );
  24.  
  25. /***************  Addressing single vector elements ******************/
  26.  
  27. unsigned long _VFAR * VUL_Pelement( ulVector X, ui n );
  28.       /* returns a pointer to the n'th element of X. For the memory model
  29.          HUGE, the pointer is normalized. */
  30. #define VUL_element( X, n ) (*VUL_Pelement( X, n ))
  31.  
  32. /****************** Initialization  ******************************/
  33.  
  34. void  __vf  VUL_equ0( ulVector X, ui size );
  35. void  __vf  VUL_equC( ulVector X, ui size, unsigned long C );
  36. void  __vf  VUL_equV( ulVector Y, ulVector X, ui size );
  37. void  __vf  VULo_ramp( ulVector X, ui size, unsigned long Start, long Rise );
  38. #ifdef V_trapIntError
  39.     #define VUL_ramp    VULo_ramp
  40. #else
  41.     void __vf  VUL_ramp( ulVector X, ui size, unsigned long Start, long Rise );
  42. #endif
  43. long  __vf  VUL_random( ulVector X, ui size, long seed,
  44.                         unsigned long MinVal, unsigned long MaxVal );
  45.                               /*  returns new seed */
  46.  
  47. /**************  Data-type interconversions  **************************/
  48.  
  49. void __vf  Vo_LItoUL( ulVector Y, liVector X, ui size );  /* signed-unsigned */
  50. void __vf  Vo_ULtoLI( liVector Y, ulVector X, ui size );
  51.  
  52. void __vf  V_UBtoUL( ulVector Y, ubVector X, ui size );  /* up-conversion */
  53. void __vf  V_UStoUL( ulVector Y, usVector X, ui size );
  54. void __vf  V_UtoUL(  ulVector Y, uVector  X, ui size );
  55.  
  56. void __vf  V_ULtoUB(  ubVector Y, ulVector X, ui size ); /* down-conversion */
  57. void __vf  Vo_ULtoUS( usVector Y, ulVector X, ui size );
  58. void __vf  Vo_ULtoU(  uVector  Y, ulVector X, ui size );
  59. #ifdef V_trapIntError
  60.     #define V_LItoUL    Vo_LItoUL
  61.     #define V_ULtoLI    Vo_ULtoLI
  62.     #define V_ULtoUS    Vo_ULtoUS
  63.     #define V_ULtoU     Vo_ULtoU
  64. #else
  65.     void  __vf   V_LItoUL( ulVector Y, liVector X, ui size );
  66.     void  __vf   V_ULtoLI( liVector Y, ulVector X, ui size );
  67.     void  __vf   V_ULtoUS( usVector Y, ulVector X, ui size );
  68.     void  __vf   V_ULtoU(  uVector  Y, ulVector X, ui size );
  69. #endif
  70.  
  71. void  __vf   V_ULtoF(  fVector Y, ulVector X, ui size );
  72. void  __vf   V_ULtoD(  dVector Y, ulVector X, ui size );
  73. #ifdef __BORLANDC__
  74.     void  __vf   V_ULtoE(  eVector Y, ulVector X, ui size );
  75. #else  /* no 80-bit IEEE reals with Visual C++ */
  76.     #define V_ULtoE V_ULtoD
  77. #endif
  78.  
  79.  
  80. /************** Index-oriented manipulations ***************************/
  81.  
  82. void  __vf  VUL_rev( ulVector Y, ulVector X, ui size );
  83. #ifdef V_HUGE
  84.     void  __vf  VUL_rotate( ulVector Y, ulVector X, ui size, long pos );
  85. #else
  86.     void  __vf  VUL_rotate( ulVector Y, ulVector X, ui size, int pos );
  87. #endif
  88.  
  89. void  __vf  VUL_delete( ulVector X, ui size, ui pos );
  90. void  __vf  VUL_insert( ulVector X, ui size, ui pos, unsigned long C );
  91.  
  92. void  __vf  VUL_sort( ulVector Y, ulVector X, ui size, int dir );
  93. void  __vf  VUL_sortind( uiVector Ind, ulVector X, ui size, int dir );
  94.  
  95. void  __vf  VUL_subvector( ulVector Y, ui sizey, ulVector X, int samp );
  96. void  __vf  VUL_subvector_equC( ulVector Y, ui subsz, unsigned samp,
  97.                                 unsigned long C );
  98. void  __vf  VUL_subvector_equV( ulVector Y, ui subsz, unsigned samp,
  99.                                 ulVector X );
  100.  
  101. void  __vf  VUL_indpick( ulVector Y, uiVector Ind, ui sizey, ulVector X );
  102. void  __vf  VUL_indput(  ulVector Y, ulVector X, uiVector Ind, ui sizex );
  103.  
  104. ui    __vf  VUL_searchC( ulVector XTab, ui size, unsigned long C, int mode );
  105. void  __vf  VUL_searchV( uiVector Ind, ulVector X, ui sizex,
  106.                          ulVector Tab, ui sizetab, int mode );
  107.  
  108. /********************   One-dimensional Vector Operations  ********/
  109.  
  110. unsigned long  __vf  VULo_sum( ulVector X, ui size );
  111. void           __vf  VULo_runsum( ulVector Y, ulVector X, ui size );
  112. #ifdef V_trapIntError
  113.     #define VUL_sum       VULo_sum
  114.     #define VUL_runsum    VULo_runsum
  115. #else
  116.     unsigned long  __vf  VUL_sum( ulVector X, ui size );
  117.     void           __vf  VUL_runsum( ulVector Y, ulVector X, ui size );
  118. #endif
  119. unsigned long  __vf  VUL_max( ulVector X, ui size );
  120. unsigned long  __vf  VUL_min( ulVector X, ui size );
  121. unsigned long  __vf  VUL_maxind( ui _VFAR *Ind, ulVector X, ui size );
  122. unsigned long  __vf  VUL_minind( ui _VFAR *Ind, ulVector X, ui size );
  123. double         __vf  VUL_fsum( ulVector X, ui size );
  124. double         __vf  VUL_mean( ulVector X, ui size );
  125. void   __vf  VUL_runmax( ulVector Y, ulVector X, ui size );
  126. void   __vf  VUL_runmin( ulVector Y, ulVector X, ui size );
  127.  
  128. int    __vf  VUL_iselementC( ulVector Tab, ui size, unsigned long  C );
  129. ui     __vf  VUL_iselementV( ulVector Y, ulVector X, ui sizex,
  130.                              ulVector Tab, ui sizetab );
  131.  
  132.  
  133. /************************ Input / Output ******************************/
  134.  
  135. void  __vf   V_ifprint(  FILE _VFAR *stream, void _VFAR *X, ui size,
  136.                   unsigned nperline, unsigned linewidth, unsigned vers );
  137. #define VUL_fprint( st, x, sz, npl, lw ) \
  138.              V_ifprint(  st, (void _VFAR *)(x), sz, npl, lw, 7 )
  139.  
  140. #if !defined _Windows || defined __FLAT__ || defined _WIN32
  141.     void __vf  V_icprint(  void _VFAR *X, ui size, unsigned nperline, unsigned vers );
  142.     #define VUL_cprint( x, sz, npl ) V_icprint( (void _VFAR *) (x), sz, npl, 7 )
  143. #endif
  144. #define VUL_print( x, sz, npl ) \
  145.              V_ifprint(  stdout, (void _VFAR *)(x), sz, npl, 80, 7 )
  146.  
  147. void  __vf   V_setRadix( int radix );
  148.            /* radix to be assumed by all whole-number read functions V??_read */
  149. void  __vf   VUL_read( ulVector X, ui size, FILE _VFAR *stream );
  150. void  __vf   VUL_write( FILE _VFAR *stream, ulVector X, ui size );
  151. void  __vf   VUL_nread( unsigned n, ui size, FILE _VFAR *stream, ... );
  152. void  __vf   VUL_nwrite( FILE _VFAR *stream, unsigned n, ui size, ... );
  153. void  __vf   VUL_setWriteFormat( char _VFAR *FormatString );
  154.                                             /* for VUL_write and VUL_nwrite */
  155. void  __vf   VUL_setWriteSeparate( char _VFAR *SepString ); /* for VUL_write */
  156. void  __vf   VUL_setNWriteSeparate( char _VFAR *SepString ); /* for VUL_nwrite */
  157. #ifdef V_HUGE
  158.     void  __vf   VUL_store(  FILE _VFAR *stream, ulVector X, ui size );
  159.     void  __vf   VUL_recall( ulVector X, ui size, FILE _VFAR *stream );
  160. #else
  161.     #ifdef __cplusplus
  162.          void  inline VUL_store( FILE _VFAR *stream, ulVector X, ui size )
  163.          {    fwrite( X, sizeof(unsigned long), size, stream ); 
  164.          }
  165.          void  inline VUL_recall( ulVector X, ui size, FILE _VFAR *stream )
  166.          {    fread(  X, sizeof(unsigned long), size, stream );
  167.          }
  168.     #else
  169.         #define VUL_store( str, X, sz )  \
  170.                      fwrite( X, sizeof(unsigned long), sz, str )
  171.         #define VUL_recall( X, sz, str ) \
  172.                      fread(  X, sizeof(unsigned long), sz, str )
  173.     #endif
  174. #endif      /* VUL_store, VUL_recall in binary format */
  175.  
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179.  
  180. #endif   /*  __VULSTD_H    */
  181.